package x的平方根;

class Solution {
    public int mySqrt(int x) {
        int left = 0;
        long right = x;
        while (left < right){
            long mid = left + (right - left + 1) / 2;
            if (mid * mid > x){
                right = mid - 1;
            }else {
                left = (int)mid;
            }
        }
        return (int)right;
    }
}